import Vue from 'vue'
import Vuex from 'vuex'

import {
  sysEvaluateQuery,
  sysEvaluateQueryById,
  sysEvaluateAdd,
  sysEvaluateGetAvgScore,
  sysEvaluateDelete,
  openApiSysEvaluateQuery,
} from '@/api/home/sysEvaluate.js'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async querySysEvaluate({ commit }, listQuery) {
    let res = await sysEvaluateQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async querySysEvaluateById({ commit }, id) {
    let res = await sysEvaluateQueryById(id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addSysEvaluate({ commit }, data) {
    let res = await sysEvaluateAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateSysEvaluate({ commit }, data) {
    let res = await sysEvaluateGetAvgScore(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteSysEvaluate({ commit }, id) {
    let res = await sysEvaluateDelete(id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async queryOpenApiSysEvaluate({ commit }, listQuery) {
    let res = await openApiSysEvaluateQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
